package com.example.teachingSystem.controller;

import com.example.teachingSystem.pojo.form.BasePageQuery;
import com.example.teachingSystem.pojo.form.TS.AddTeachForm;
import com.example.teachingSystem.pojo.form.TS.UpdateTeachForm;
import com.example.teachingSystem.pojo.vo.TeachInfoVo;
import com.example.teachingSystem.service.TeacherService;
import com.example.teachingSystem.utils.result.PageResult;
import com.example.teachingSystem.utils.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/teach")
@Tag(name="教师管理模块")
public class TeacherController {

    @Autowired
    private TeacherService teacherService;

    @PostMapping("/addTeach")
    @Operation(summary = "添加教师",security = {@SecurityRequirement(name = "Authorization")})
    public Result<String> adminAddTeacher(@RequestBody AddTeachForm addTeachForm){
        return teacherService.adminAddTeacher(addTeachForm);
    }

    @DeleteMapping("/deleteTeach/{teachId}")
    @Operation(summary = "删除教师",security = {@SecurityRequirement(name = "Authorization")})
    public Result<String> adminDeleteTeacher(@PathVariable Long teachId){
        return teacherService.adminDeleteTeacher(teachId);
    }

    @GetMapping("/getById/{teachId}")
    @Operation(summary = "根据id获得教师信息",security = {@SecurityRequirement(name = "Authorization")})
    public Result<TeachInfoVo>getTeacherById(@PathVariable Long teachId){
        return teacherService.getTeacherById(teachId);
    }

    @GetMapping ("/getAllTeach")
    @Operation(summary = "获取教师列表",security = {@SecurityRequirement(name = "Authorization")})
    public PageResult<TeachInfoVo> adminGetTeacher(@ParameterObject BasePageQuery basePageQuery){
        return teacherService.adminGetTeacher(basePageQuery);
    }

    @PostMapping("/updateTeach")
    @Operation(summary = "修改教师",security = {@SecurityRequirement(name = "Authorization")})
    public Result<String> adminUpadeTeacher(@RequestBody UpdateTeachForm updateTeachForm){
        return teacherService.adminUpadeTeacher(updateTeachForm);
    }
}
